﻿using System;

namespace Lottery.App.Model
{
    public class RecordInfo
    {
        public RecordInfo() { }

        public RecordInfo(string date, string result)
            : this(date.Substring(0, 8), Convert.ToInt32(date.Substring(8)), result)
        {
            
        }

        public RecordInfo(string date, int num, string result)
        {
            this.Date = date;
            this.Num = num;

            this.Result = result;
            this.ASC_Result = Utils.Sort(this.Result);
            
            this.A1 = result.Substring(0, 2);
            this.A2 = result.Substring(0, 5);
            this.A3 = result.Substring(0, 8);
            this.P2 = Utils.Sort(this.A2);
            this.P3 = Utils.Sort(this.A3);
        }

        public virtual int ID { get; private set; }

        public virtual string Date { get; set; }

        public virtual int Num { get; set; }

        public virtual string Result { get; set; }

        public virtual string ASC_Result { get; set; }

        public virtual string A1 { get; set; }

        public virtual string A2 { get; set; }

        public virtual string A3 { get; set; }

        public virtual string P2 { get; set; }

        public virtual string P3 { get; set; }

        public virtual string IssueNum
        {
            get {
                return String.Format("{0}{1:D3}", Date, Num);
            }
        }
    }
}
